package com.example.home_stretch;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.haibin.calendarview.Calendar;
import com.haibin.calendarview.CalendarView;

public class Rl extends AppCompatActivity {
    private CalendarView calendarView;
    private TextView tv_gl;
    private TextView tv_jr;
    private TextView tv_nl;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rl);
        initView();
    }
    private void initView() {
        calendarView = (CalendarView) findViewById(R.id.calendarView);
        tv_gl = (TextView) findViewById(R.id.tv_gl);
        tv_jr = (TextView) findViewById(R.id.tv_jr);
        tv_nl = (TextView) findViewById(R.id.tv_nl);
        //设置日历的专属点击事件，一定要看清因为很多点击事件和日历的点击事件很相似
        calendarView.setOnCalendarSelectListener(new CalendarView.OnCalendarSelectListener() {
            @Override
            public void onCalendarOutOfRange(Calendar calendar) {
                //日历超出范围运行
            }
            @Override
            public void onCalendarSelect(Calendar calendar, boolean isClick) {
                tv_jr.setText("节日:"+calendar.getGregorianFestival());//设置节日的方法
                tv_nl.setText("农历:"+calendar.getLunar());//设置农历
                tv_gl.setText("公历:"+calendar.getLunarCalendar());//设置公历
            }
        });
    }
}
